#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, l, V;
ll a[100005], d[100005], v[100005], p[100005];
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    scanf("%d", &T);
    while (T --){
        int ans = 0;
        scanf("%lld%lld%lld%lld", &n, &m, &l,&V);
        bool f = 1;
        for (int i = 1; i <= n; i ++){
            scanf("%lld%lld%lld", &d[i], &v[i], &a[i]);
            if (a[i]!=0) f=0;
        }
        for (int i = 1; i <= m; i ++){
            scanf("%lld", &p[i]);
        }
        if (f){
            int tt = p[m];
            for (int i = 1; i <= n; i ++){
                if (v[i] > V && d[i]<=tt) ans ++;
            }
            if (ans == 0) m ++;
            printf("%d %lld\n", ans, m - 1);
            continue;
        }
        for (int i = 1; i <= n; i ++){
            if (V*V-v[i]*v[i]+d[i]*(2*a[i]) < p[m]*(2*a[i])) ans ++;
        }
        if(ans == 0) m++;
        printf("%d %lld\n", ans, m - 1);
    }
    return 0;
}